package com.atguigu01.string.exer2;

import org.junit.Test;

/**
 * ClassName: MyStringAnswers
 * Package: com.atguigu01.string.exer2
 * Description:
 *
 * @Author BuTang
 * @Create 2023/5/22 18:13
 * @Version 1.0
 */
public class MyStringAnswers {
    String s = "  abcde  ";

    @Test
    public void trim(String s1) {
        s1 = s;
        int start = 0;
        int end = s.length() - 1;
        while (true) {
            if (s1.indexOf(' ') >= 0) {
                start++;
                s1 = s1.substring(start, s1.length());
                break;
//            }
//            if (s1.lastIndexOf(' ') >= 0) {
//                end--;
//                s1 = s1.substring(0,end);
//            }
//            if (s1.indexOf(' ') < 0 && s1.lastIndexOf(' ') < 0) break;
            }
            System.out.println(s1.substring(start, end));
        }
    }
}
